# -*- coding:utf-8 -*- 

class Solution(object):
    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        """
        map = {}
        sub_max = 0
        j = 0
        for i in range(len(s)):
            if s[i] in map:
                j = max(j, map[s[i]]+1)
            map[s[i]] = i
            sub_max = max(sub_max, i-j+1)
        return sub_max

if __name__ == "__main__":
    s = "tmmzuxt"
    print Solution().lengthOfLongestSubstring(s)
                
